<title>通知管理</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>问答管理</cite></a>
    <a><cite>通知管理</cite></a>
  </div>
</div>


<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
  <div class="layui-card">
   <div class="layui-card-header">通知管理</div>
    <div class="layui-card-body">
    
      <div style="padding-bottom: 10px;">
        <a href="#J_add_tpl" class="layui-btn J_popup" title="发布通知"><i class="layui-icon layui-icon-add-circle"></i>发布通知</a>
        <a href="wendasns/notice/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
      </div>
      
      <table id="J_table_list" lay-filter="J_table_list"></table>
    </div>
    
  </div>
</div>
  </div>
</div>

<script type="text/html" id="J_table_status_tpl">
        {{#  if(d.status == 1){ }}
          <span class="layui-badge layui-bg-green">是</span>
        {{#  } else{ }}
        	<span class="layui-badge layui-bg-orange">否</span>
        {{#  } }}
</script>
      
<script type="text/html" id="J_table_tool">
  <a href="#J_edit_tpl" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑通知"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="wendasns/notice/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>

<script>
;!function(){
  var $ = layui.$
  ,admin = layui.admin
  ,table = layui.table
  ,laydate = layui.laydate
  ,form = layui.form;

    lay('.J_dataTime').each(function(){
      laydate.render({
        elem: this
      });
    });

  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('wendasns/notice/list')}'
  ,cols: [[
      {type: 'checkbox',fixed:'left'}
      ,{field:'id',title:'ID',align:'center',width:100}
      ,{field:'username',title:'收件人',width:150}
      ,{field:'title',title:'标题',minWidth:200}
      ,{field:'create_time',title:'发布时间',width:160}
      ,{field:'status',title:'是否阅读',width:100,align:'center',templet:'#J_table_status_tpl'}
      ,{title:'操作',width:150,align:'center',toolbar:'#J_table_tool'}
  ]]
  ,page: true
  ,limit: 20
  ,height: 'auto'
  ,text: {
    none: '暂无数据！'
  }
});

  form.on('select(select_type)', function(obj){
    $('.type_all').hide();
    $('.type_'+obj.value).show();
  });


}();
</script>

<script type="text/html" id="J_add_tpl">
          <form class="layui-form" lay-filter="J_ajaxForm" action="{:url('wendasns/notice/add')}" method="post">

            <div class="layui-form-item">
              <label class="layui-form-label">收件用户</label>
              <div class="layui-input-inline">
                <select lay-filter="select_type" name="type">
                  <option value="0">按用户名</option>
                  <option value="1">按用户组</option>
                </select>
              </div>
            </div>
            
            <div class="layui-form-item type_all type_1" style="display: none;">
              <label class="layui-form-label">用户组</label>
              <div class="layui-input-inline">
                <select name="group">
                  {volist name="group" id="item"}
                  {if $item.type eq 'default'}
                  <option value="{$item.id}">{$item.name}</option>
                  {/if}
                  {/volist}
                </select>
              </div>
              <div class="layui-form-mid layui-word-aux">所选用户组所有人都收到通知</div>
            </div>

            <div class="layui-form-item type_all type_2">
              <label class="layui-form-label">用户名</label>
              <div class="layui-input-inline" style="width: 350px;">
                <input type="text" name="username" value="" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">多个用户名用空格分开</div>
            </div>
            
            <div class="layui-form-item">
              <label class="layui-form-label">标题</label>
              <div class="layui-input-inline" style="width: 350px;">
                <input type="text" name="title" value="" lay-verify="required" class="layui-input">
              </div>
            </div>


            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">内容</label>
              <div class="layui-input-inline" style="width: 350px;">
                <textarea name="content" class="layui-textarea" lay-verify="required"></textarea>
              </div>
              <div class="layui-form-mid layui-word-aux">支持html代码</div>
            </div>
            
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn">提交</button>
              </div>
            </div>
          </form>
</script>

<script type="text/html" id="J_edit_tpl">
          <form class="layui-form" action="{:url('wendasns/notice/edit')}" method="post">
          	<input type="hidden" name="id" value="{{d.id||0}}">
          	
            <div class="layui-form-item">
              <label class="layui-form-label">收件人</label>
              <div class="layui-input-inline" style="width: 350px;">
                <input type="text" value="{{d.username||''}}" disabled="disabled" class="layui-input layui-disabled">
              </div>
            </div>
            
            <div class="layui-form-item">
              <label class="layui-form-label">标题</label>
              <div class="layui-input-inline" style="width: 350px;">
                <input type="text" name="title" value="{{d.title||''}}" lay-verify="required" class="layui-input">
              </div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">内容</label>
              <div class="layui-input-inline" style="width: 350px;">
                <textarea name="content" class="layui-textarea" lay-verify="required">{{d.content||''}}</textarea>
              </div>
              <div class="layui-form-mid layui-word-aux">支持html代码</div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">发布时间</label>
              <div class="layui-input-inline" style="width: 350px;">
                <input type="text" name="create_time" value="{{d.create_time||''}}" class="layui-input J_dataTime">
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">状态</label>
              <div class="layui-input-inline">
                <input type="radio" name="status" value="1" title="已读" {{d.status==1?'checked':''}}>
                <input type="radio" name="status" value="0" title="未读" {{d.status==0?'checked':''}}>
              </div>
            </div>
            
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
              </div>
            </div>
          </form>
</script>